home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / clients / editres / editresp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-12  |  8.9 KB  |  298 lines

  1. /*
  2.  * $XConsortium: editresP.h,v 1.12 91/07/30 15:30:47 rws Exp $
  3.  *
  4.  * Copyright 1989 Massachusetts Institute of Technology
  5.  *
  6.  * Permission to use, copy, modify, distribute, and sell this software and its
  7.  * documentation for any purpose is hereby granted without fee, provided that
  8.  * the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of M.I.T. not be used in advertising or
  11.  * publicity pertaining to distribution of the software without specific,
  12.  * written prior permission.  M.I.T. makes no representations about the
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  17.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  18.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  20.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  21.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  *
  23.  * Author:  Chris D. Peterson, MIT X Consortium
  24.  */
  25.  
  26. #include <X11/Xmu/EditresP.h>
  27. #include <X11/Xresource.h>
  28.  
  29. #define DEBUG
  30.  
  31. #ifdef DEBUG
  32. #  define CLIENT_TIME_OUT 60000    /* wait sixty seconds for the client. */
  33. #else
  34. #  define CLIENT_TIME_OUT 5000    /* wait five seconds for the client. */
  35. #endif /* DEBUG */
  36.  
  37. #define CURRENT_PROTOCOL_VERSION 4
  38.  
  39. #define FLASH_TIME  1000    /* Default flash time in microseconds */
  40. #define NUM_FLASHES 3        /* Default number of flashes. */
  41.  
  42. #define NO_IDENT 0        /* an ident that will match nothing. */
  43.  
  44. #define NUM_INC 10        /* amount to increment allocators. */
  45.  
  46. #define ANY_RADIO_DATA ("the any widget")
  47. #define RESOURCE_BOX ("resourceBox")
  48.  
  49. #ifndef MSDOS
  50. extern void exit();
  51. #endif
  52.  
  53. /*
  54.  * Retrieving ResType and Boolean is the same as retrieving a Card8.
  55.  */
  56.  
  57. #define _XEditResGetBoolean _XEditResGet8
  58. #define _XEditResGetResType _XEditResGet8
  59.  
  60. /*
  61.  * Contexts to use with the X Context Manager.
  62.  */
  63.  
  64. #define NODE_INFO ((XContext) 42)
  65.  
  66. /*
  67.  * Error codes for X Server errors. 
  68.  */
  69.  
  70. #define NO_ERROR 0
  71. #define NO_WINDOW 1
  72.  
  73. typedef enum {LocalSendWidgetTree, LocalSetValues, LocalFindChild, 
  74.           LocalFlashWidget, LocalGetGeometry, LocalGetResources}ResCommand;
  75.  
  76. typedef enum {ClassLabel, NameLabel, IDLabel, WindowLabel,
  77.           ToggleLabel} LabelTypes;
  78. typedef enum {SelectWidget, SelectAll, SelectNone, SelectInvert, SelectParent, 
  79.           SelectChildren,  SelectDescendants, SelectAncestors} SelectTypes;
  80.  
  81. typedef struct _NameInfo {
  82.     struct _NameInfo * next;    /* Next element in the linked list. */
  83.     Widget sep_leader;        /* The separator toggle group leader. */
  84.     Widget name_leader;        /* The name toggle group leader. */
  85. } NameInfo;
  86.  
  87. typedef struct _ResourceBoxInfo {
  88.     Widget value_wid;        /* The string containing the value. */
  89.     Widget res_label;        /* The label containing current resoruce. */
  90.     Widget shell;        /* Shell widget containing resource box. */
  91.     Widget norm_list;        /* The List widget for the normal list. */
  92.     Widget cons_list;        /* The List widget for the 
  93.                    Constriaint Resources */
  94.     NameInfo * name_info;    /* The info about the widgets for each
  95.                    name and class in the instance heirarchy. */
  96. } ResourceBoxInfo;
  97.     
  98. typedef struct _WidgetResourceInfo {
  99.     char * name, * class, *type; /* Name, Class and Type of each resource. */
  100. } WidgetResourceInfo;
  101.     
  102. typedef struct _WidgetResources {
  103.     int num_normal, num_constraint;
  104.     WidgetResourceInfo *normal, *constraint;
  105.     ResourceBoxInfo * res_box;
  106. } WidgetResources;
  107.  
  108. typedef struct _WNode {
  109.     char * name;
  110.     char * class;
  111.     unsigned long id, window;
  112.     struct _WNode * parent;
  113.     struct _WNode ** children;
  114.     struct _TreeInfo * tree_info;
  115.     Cardinal num_children, alloc_children;
  116.     Widget widget;
  117.     WidgetResources * resources;
  118. } WNode;
  119.  
  120. /*
  121.  * Information for the Select any widget, toggle buttons in the resource
  122.  * boxes.
  123.  */
  124.  
  125. typedef struct _AnyInfo {
  126.     WNode * node;        /* A Pointer off to the node corrsponding to
  127.                    this resource box. */
  128.     Widget left_dot, left_star;    /* The dot and star widgets to our left. */
  129.     Widget right_dot, right_star; /* The dot and star widgets to our right. */
  130.     int left_count, *right_count; /* If count > 0 then desensitize the left or
  131.                     right dot and star widgets. */
  132. } AnyInfo;
  133.  
  134. /*
  135.  * Information about the client we are currently working with.
  136.  */
  137.  
  138. typedef struct _CurrentClient {
  139.     ResCommand command;        /* the command sent. */
  140.     ResIdent ident;
  141.     ProtocolStream stream;    /* protocol stream for this client. */
  142.     XtIntervalId timeout;    /* timeout set in case he doesn't answer. */
  143.     Window window;        /* window to communicate with. */
  144.     Atom atom;            /* Atom used to communicate with this client.*/
  145. } CurrentClient;
  146.  
  147. /*
  148.  * Information about a tree we can display.
  149.  */
  150.  
  151. typedef struct _TreeInfo {
  152.     Widget tree_widget;        /* The Tree widget that contains all nodes */
  153.     WNode * top_node;        /* The top node in the tree. */
  154.     WNode ** active_nodes;    /* The currently active nodes. */
  155.     Cardinal num_nodes, alloc_nodes; /* number of active nodes, and space */
  156.     Widget * flash_widgets;    /* list of widgets to flash on and off. */
  157.     Cardinal num_flash_widgets, alloc_flash_widgets; /* number of flash wids.*/
  158. } TreeInfo;
  159.  
  160. /*
  161.  * Information specific to a give APPLICATION screen.
  162.  */
  163.  
  164. typedef struct _ScreenData {
  165.     Widget set_values_popup;    /* The SetValues popup. */
  166.     Widget res_text;        /* SetValues resource text widget. */
  167.     Widget val_text;        /* SetValues value text widget. */
  168.     Widget info_label;            /* The information label. */
  169. } ScreenData;
  170.  
  171. typedef struct _AppResources {
  172.     Boolean debug;        /* Is debugging on? */
  173.     int num_flashes, flash_time; /* Number and duration of flashes. */
  174.     Pixel flash_color;        /* Color of flash window. */
  175.     char * save_resources_file;    /* File to save the resources into. */
  176.  
  177.     /* Private state */
  178.     Boolean allocated_save_resources_file;
  179. } AppResources;
  180.  
  181. /*
  182.  * Information needed to apply the resource string to all widgets.
  183.  */
  184.  
  185. typedef struct _ApplyResourcesInfo {
  186.     char * name, *class;    /* name and class  of this resource. */
  187.     unsigned short count;
  188.     ProtocolStream * stream;
  189.     XrmDatabase database;
  190. } ApplyResourcesInfo;
  191.     
  192.  
  193. /************************************************************
  194.  *
  195.  * The Event Structures.
  196.  *
  197.  ************************************************************/
  198.  
  199. typedef struct _AnyEvent {
  200.     EditresCommand type;
  201. } AnyEvent;
  202.  
  203. typedef struct _WidgetTreeInfo {
  204.     WidgetInfo widgets;
  205.     char * name;
  206.     char * class;
  207.     unsigned long window;
  208. } WidgetTreeInfo;
  209.  
  210. typedef struct _SendWidgetTreeEvent {
  211.     EditresCommand type;
  212.     unsigned short num_entries;
  213.     WidgetTreeInfo * info;
  214. } SendWidgetTreeEvent;
  215.  
  216. typedef struct _SetValuesInfo {
  217.     WidgetInfo widgets;
  218.     char * message;
  219. } SetValuesInfo;
  220.     
  221. typedef struct _SetValuesEvent {
  222.     EditresCommand type;
  223.     unsigned short num_entries;
  224.     SetValuesInfo * info;
  225. } SetValuesEvent;
  226.  
  227. typedef struct _ResourceInfo {
  228.     ResourceType res_type;
  229.     char * name, *class, *type;
  230. } ResourceInfo;
  231.  
  232. typedef struct _GetResourcesInfo {
  233.     WidgetInfo widgets;
  234.     Boolean error;
  235.     char * message;
  236.     unsigned short num_resources;
  237.     ResourceInfo * res_info;
  238. } GetResourcesInfo;
  239.  
  240. typedef struct _GetResourcesEvent {
  241.     EditresCommand type;
  242.     unsigned short num_entries;
  243.     GetResourcesInfo * info;
  244. } GetResourcesEvent;
  245.  
  246. typedef struct _GetGeomInfo {
  247.     EditresCommand type;
  248.     WidgetInfo widgets;
  249.     Boolean error;
  250.     char * message;
  251.     Boolean visable;
  252.     short x, y;
  253.     unsigned short width, height, border_width;
  254. } GetGeomInfo;
  255.  
  256. typedef struct _GetGeomEvent {
  257.     EditresCommand type;
  258.     unsigned short num_entries;
  259.     GetGeomInfo * info;
  260. } GetGeomEvent;
  261.  
  262. typedef struct _FindChildEvent {
  263.     EditresCommand type;
  264.     WidgetInfo widgets;
  265. } FindChildEvent;
  266.  
  267. typedef union _Event {
  268.     AnyEvent any_event;
  269.     SendWidgetTreeEvent send_widget_tree_event;
  270.     SetValuesEvent set_values_event;
  271.     GetResourcesEvent get_resources_event;
  272.     GetGeomEvent get_geom_event;
  273.     FindChildEvent find_child_event;
  274. } Event;
  275.     
  276. /*
  277.  * Global variables. 
  278.  */
  279.  
  280. #ifndef THIS_IS_MAIN
  281.     extern int global_error_code;
  282.     extern unsigned long global_serial_num;
  283.     extern int (*global_old_error_handler)();
  284.     extern Boolean global_resource_box_up;
  285.  
  286.     extern TreeInfo *global_tree_info;
  287.     extern CurrentClient global_client;
  288.     extern ScreenData global_screen_data;
  289.     extern Widget global_tree_parent;
  290.     extern AppResources global_resources;
  291. #endif
  292.  
  293. /*
  294.  * Macros.
  295.  */
  296.  
  297. #define streq(a, b)        ( strcmp((a), (b)) == 0 )
  298.